<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Qnr extends Model
{

    use HasFactory;

    /**
     * 关联到模型的数据表.
     *
     * @var string
     */
    protected $table = 'qnr';

    /**
     * 可以被批量赋值的属性。
     *
     * @var array
     */
    protected $fillable = [
        'title',
        'user_id',
        'qnr_id',
        'c_key',
        't_key',
        'slug',
        'introduction',
        'content',
        'address',
        'is_top',
        'sponsor',
        'telephone',
        'is_comments',
        'is_using',
        'options',
        'images',
        'thumbnail',
    ];

    /**
     * 问卷标签
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function tags()
    {
        return $this->belongsToMany(QnrTags::class);
    }

    /**
     * 帖子分类
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function qnr_cls()
    {
        return $this->belongsTo('App\Models\QnrCls','c_key','id');
    }

    /**
     * 用户
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function admin_users()
    {
        return $this->belongsTo('App\Models\AdminUsers','admin_id','id');
    }
}
